﻿@model Backend.JYD.Model.Task.TaskBaseInfo
@using Backend.JYD.Model.Task
@using Backend.JYD.Model.Auth
@using Backend.JYD.Business
@{
    var manager = new TaskManager();
    var step = Html.ViewData["Step"] as TaskStepModel;
    var auth = Html.ViewData["Auth"] as List<AuthorityInfo>;
    var showControl = manager.CheckTaskOperation(Model, step, auth);
    if (showControl != null)
    {
        if (showControl.AllowBeginHandout || showControl.AllowProcessHandOut)
        {
            <input type="button" value="分派" title="分派任务" onclick="handout(@Model.TaskId);"/>
        }
        if(showControl.AllowBeginMarketing)
        {
            <input type="button" value="营销任务" title="营销任务" onclick="marketing(@Model.TaskId, '@Model.TaskDetailId');" />
        }
        if(showControl.AllowBeginProcess)
        {
           <input type="button" value="开始处理" title="开始处理" onclick="process(@Model.TaskId, '@(step == null ? string.Empty : step.StepCode.ToLower())', '@TaskManager.TaskStatus.Beginning.ToString().ToLower()');"/>
        }
        if (showControl.AllowProcessMarketing)
        {
            <input type="button" value="处理营销任务" title="处理营销任务" onclick="showmarketing();" />
        }
        if (showControl.AllowProcessReturnToLast)
        {
            <input type="button" value="返回" title="当前未执行完成，返回到前面步骤" onclick="process(@Model.TaskId, '@(step == null ? string.Empty : step.StepCode.ToLower())', '@TaskManager.TaskStatus.ReturnToLast.ToString().ToLower()');"/>
        }
        if (showControl.AllowProcessCompleteAndLoop)
        {
            <input type="button" value="循环步骤" title="循环步骤" onclick="process(@Model.TaskId, '@(step == null ? string.Empty : step.StepCode.ToLower())', '@TaskManager.TaskStatus.CompleteAndLoop.ToString().ToLower()');"/>
        }
        if (showControl.AllowProcessCompleteAndReady)
        {
        <input type="button" value="提交" title="当前任务完成，提交到下一步" onclick="commit(@Model.TaskId);"/>
        }
        if (showControl.AllowProcessComplete)
        {
        <input type="button" value="结束/终止" title="任务结束，任务终止" onclick="process(@Model.TaskId, '@(step == null ? string.Empty : step.StepCode.ToLower())', '@TaskManager.TaskStatus.Complete.ToString().ToLower()');"/>
        }
    }
}